LicenseManager

@objc(LSLicenseManager)
final class LicenseManager : BaseManager
extension LicenseManager : CVarArg, CustomDebugStringConvertible, CustomStringConvertible, Equatable, Hashable, NSObjectProtocol

Entry point to the LicenseSpring SDK Use to obtain the license or common product information

  • Init LicenseManager with configuration

    Throws

    LSError if the configuration is invalid or the client cannot be initialized.

    Note

    In Objective-C, pass an instance conforming to the LSBaseStorage protocol for baseStorage. In Swift, pass an instance conforming to BaseStorage.

    Declaration

    Swift

    @objc
    init(configuration: Configuration, baseStorage: AnyObject? = nil) throws

    Parameters

    configuration

    Configuration of LicenseManager

    baseStorage

    An optional object used for low-level data storage operations such as reading, writing, and deleting raw license data. Accepts either a Swift implementation conforming to BaseStorage or an Objective-C object conforming to LSBaseStorage. If nil, the default internal file-based storage is used. This parameter is primarily intended for advanced customization of how license files are persisted.

  • Activated License or nil if no license is active.

    Declaration

    Swift

    @objc
    var currentLicense: License? { get }
  • Base Storage object passed by the user for custom license storage implementation

    Declaration

    Swift

    let baseStorage: any BaseStorage
  • Activate the license using license key.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(licenseKey: String) throws -> License

    Parameters

    licenseKey

    License key for the product.

    Return Value

    Activated license.

  • Undocumented

    Declaration

    Swift

    @objc
    func saveToFile() throws
  • Activate the license using a license key asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(licenseKey: String, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key for the product.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Activate the license using user and password.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String) throws -> License

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Activated license.

  • Activate the license using user and password asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Activate the license using serverId.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String, serverId: Int64) throws -> License

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Activated license.

  • Activate the license using user, password, and server ID asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String, serverId: Int64, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    serverId

    License ID, typically a 64-bit ID.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Activate the license using serverID.

    Declaration

    Swift

    @objc(testGetActivateLicenseWithServerId:error:)
    func activateLicense(serverId: LicenseIDObjc) throws -> License

    Parameters

    serverId

    License ID, typically a LicenseIDObjc. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Activate the license using license activation response file.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicenseOffline(_ activationResponseFile: URL) throws -> License

    Parameters

    activationResponseFile

    Activation response file location.

    Return Value

    Activated license.

  • Activate the license using license activation response file asynchronously.

    Declaration

    Swift

    @objc
    func activateLicenseOffline(_ activationResponseFile: URL, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    activationResponseFile

    Activation response file location.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Creates offline activation file request.

    Throws

    Error if create activation file fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func createOfflineActivationFile(licenseKey: String, preferredLocation: URL? = nil) throws -> URL

    Parameters

    licenseKey

    License key to be activated offline.

    preferredLocation

    Optional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.

    Return Value

    Location of offline activation file request.

  • Creates offline activation file request.

    Throws

    Error if create activation file fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func createOfflineActivationFile(user: String, password: String, preferredLocation: URL? = nil, serverID: Int64 = 0) throws -> URL

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    preferredLocation

    Optional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.

    serverID

    serverID, server-side license identifier, typically 64-bit id.

    Return Value

    Location of offline activation file request.

  • Get Activation code for air gap activation.

    Throws

    Error if generation fails. May be of LSError type.

    Declaration

    Swift

    @available(macOS, introduced: 10.15)
    @available(iOS, introduced: 13.0)
    @objc
    func generateAirGapActivationCode(initializationCode: String, licenseKey: String) throws -> String

    Parameters

    initializationCode

    Code received from the air gap activation portal.

    licenseKey

    License key of air gap license.

    Return Value

    Air gap Activation code. Empty string in case of error.

  • Verify Confirmation code for air gap activation.

    Throws

    Error if verification fails. May be of LSError type.

    Declaration

    Swift

    @available(macOS, introduced: 10.15)
    @available(iOS, introduced: 13.0)
    @objc
    func verifyAirGapConfirmationCode(confirmationCode: String, licenseKey: String, policyID: Int) throws

    Parameters

    confirmationCode

    Code received from the air gap activation portal.

    licenseKey

    License key of air gap license.

    policyID

    Policy id received from the air gap activation portal.

  • Activate air gap license using policy file.

    Throws

    Error if activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int) throws -> License

    Parameters

    licenseKey

    License key.

    policyID

    Id of the license policy.

    Return Value

    License if activation succeeded.

  • Activate air gap license using policy file asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key.

    policyID

    ID of the license policy.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Retrieve URL for Single Sign-On license activation.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestSSOURL(useAuthCode: Bool = true, redirectURI: String = "") throws -> URL

    Parameters

    useAuthCode

    If true (default), generates an SSO URL for the Authorization Code flow. If false, uses the Implicit flow.

    redirectURI

    Optional redirect URI to use. Must be one of the allowed redirect URIs for the customer account. If empty or nil, the default (first) redirect URI is used.

    Return Value

    URL for Single Sign-On.

  • Retrieve URL for Single Sign-On license activation.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc(requestSSOURLDetailedWithUseAuthCode:redirectURI:error:)
    func requestSSOURL(useAuthCode: Bool = true, redirectURI: String = "") throws -> SSOURL

    Parameters

    useAuthCode

    If true (default), generates an SSO URL for the Authorization Code flow. If false, uses the Implicit flow.

    redirectURI

    Optional redirect URI to use. Must be one of the allowed redirect URIs for the customer account. If empty or nil, the default (first) redirect URI is used.

    Return Value

    SSOURL for Single Sign-On.

  • Retrieve all available SSO URLs. The first element is the main SSO URL, followed by alternate URLs in the order received from the License API.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func getAllSSOUrls(useAuthCode: Bool = true, redirectURI: String = "") throws -> [URL]

    Parameters

    useAuthCode

    If true (default), generates SSO URLs for the Authorization Code flow. If false, uses the Implicit flow.

    redirectURI

    Optional redirect URI to use. Must be one of the allowed redirect URIs for the customer account. If empty or nil, the default (first) redirect URI is used.

    Return Value

    Array of SSO URLs with the main URL first.

  • Activate the license using SSO token.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(ssoToken: String, redirectURI: String? = nil, useAuthCode: Bool = true) throws -> License

    Parameters

    ssoToken

    Authorization code or ID token received from SSO login, depending on the flow.

    redirectURI

    The redirect URI that was used during the SSO login flow. Must match the redirect_uri from the SSO URL. Only used with Authorization Code flow. Pass nil if using the default redirect URI.

    useAuthCode

    If true (default), the ssoToken is treated as an authorization code. If false, it is treated as an ID token (Implicit flow).

    Return Value

    Activated license.

  • Activate the license using SSO token asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(ssoToken: String, redirectURI: String? = nil, useAuthCode: Bool = true, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    ssoToken

    Authorization code or ID token received from SSO login, depending on the flow.

    redirectURI

    The redirect URI that was used during the SSO login flow. Must match the redirect_uri from the SSO URL. Only used with Authorization Code flow. Pass nil if using the default redirect URI.

    useAuthCode

    If true (default), the ssoToken is treated as an authorization code. If false, it is treated as an ID token (Implicit flow).

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Request trial license from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(with email: String?) throws -> String

    Return Value

    Trial license key or user email in case of user-based product.

  • Request trial license from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(for customer: Customer?, licensePolicy: String? = nil) throws -> String

    Parameters

    licensePolicy

    License policy code. If nil, the default license policy for the product will be used.

    Return Value

    Trial license key or user email in case of user-based product.

  • Request trial license from LicenseSpring platform.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(with email: String?, completion: @escaping (String?, (any Error)?) -> Void)

    Parameters

    completion

    Trial license key or user email in case of user-based product if request succeeds, Error if request fails. May be of LSError type.

  • Request all available versions for the license user.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(licenseKey: String, env: String? = nil) throws -> [AvailableVersion]

    Parameters

    licenseKey

    License key.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    An array of versions available for the license.

  • Request all available versions for the license user.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(licenseKey: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    An array of versions available for the license if request succeeds, Error if request fails. May be of LSError type.

  • Request all available versions for the license user.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(user: String, env: String? = nil) throws -> [AvailableVersion]

    Parameters

    user

    License user name, usually email in lowercase.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    An array of versions available for the license.

  • Request all available versions for the license user.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(user: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)

    Parameters

    user

    License user name, usually email in lowercase.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    An array of versions available for the license if request succeeds, Error if request fails. May be of LSError type.

  • Request installation information for the license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil) throws -> InstallationFile

    Parameters

    licenseKey

    License key.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    Installation information related to the license.

  • Request installation information for the license.

    Declaration

    Swift

    @objc
    func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    Installation information related to the license if request succeeds, Error if request fails. May be of LSError type.

  • Request installation information for the license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestInstallationFile(user: String, version: String? = nil, env: String? = nil) throws -> InstallationFile

    Parameters

    user

    License user name, usually email in lowercase.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    Installation information related to the license.

  • Request installation information for the license.

    Declaration

    Swift

    @objc
    func requestInstallationFile(user: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)

    Parameters

    user

    License user name, usually email in lowercase.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    Installation information related to the license if request succeeds, Error if request fails. May be of LSError type.

  • Request information about the product from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    In offline mode data will be retrieved from license file if present.

    Declaration

    Swift

    @objc
    func requestProductDetails(env: String? = nil) throws -> ProductDetails

    Parameters

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    Product details.

  • Request information about the product from LicenseSpring platform.

    Note

    In offline mode data will be retrieved from license file if present.

    Declaration

    Swift

    @objc
    func requestProductDetails(env: String? = nil, completion: @escaping (ProductDetails?, (any Error)?) -> Void)

    Parameters

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    Product details if request succeeds, Error if request fails. May be of LSError type.

  • Request all the license users on every order by some customer.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestLicenseUsers(for customerEmail: String) throws -> [User]

    Return Value

    Array of the users related to the customer.

  • Request all the license users on every order by some customer.

    Declaration

    Swift

    @objc
    func requestLicenseUsers(for customerEmail: String, completion: @escaping ([User]?, (any Error)?) -> Void)

    Parameters

    completion

    Array of the users related to the customer if request succeeds, Error if request fails. May be of LSError type.

  • Change password for user based license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func changePassword(user: String, password: String, newPassword: String) throws

    Parameters

    user

    User email.

    password

    Current user password.

    newPassword

    New user password.

  • Change password for user based license.

    Declaration

    Swift

    @objc
    func changePassword(user: String, password: String, newPassword: String, completion: @escaping ((any Error)?) -> Void)

    Parameters

    user

    User email.

    password

    Current user password.

    newPassword

    New user password.

    completion

    Error if request fails. May be of LSError type.

  • Helper method to check connection to the LicenseSpring platform.

    Declaration

    Swift

    @objc
    func checkConnection() -> Bool

    Return Value

    true if SDK is able to connect to the LicenseSpring platform and false otherwise.

  • Helper method to check connection to the LicenseSpring platform.

    Declaration

    Swift

    @objc
    func checkConnection(completion: @escaping (Bool) -> Void)

    Parameters

    completion

    true if SDK is able to connect to the LicenseSpring platform and false otherwise

  • Remove license file and internal SDK files if any of them exist.

    Note

    Typically should be called after license deactivation in the app uninstaller.

    Throws

    Error if clearing fails.

    Declaration

    Swift

    @objc
    func clearLocalStorage() throws
  • Gets the users licences using user and password

    Declaration

    Swift

    @objc
    func getUserLicenses(user: String, password: String) throws -> [UserLicensesData]

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Array of UserLicensesData

  • Gets the users licences using user and password

    Declaration

    Swift

    @objc(getUserLicenseIDsWithUser:password:error:)
    func getUserLicenses(user: String, password: String) throws -> [LicenseIDObjc]

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Array of UserLicensesData

  • Gets the users licences using user and password

    Declaration

    Swift

    @objc
    func getUserLicenses(user: String, password: String, completion: @escaping ([UserLicensesData]?, (any Error)?) -> Void)

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    completion

    Array of UserLicensesData, Error if request fails. May be of LSError type.

  • Gets the user’s licenses using SSO token.

    Declaration

    Swift

    @objc
    func getUserLicenses(ssoToken: String, redirectURI: String? = nil, useAuthCode: Bool = true) throws -> [UserLicensesData]

    Parameters

    ssoToken

    Authorization code or ID token received from SSO user authorization, depending on the flow.

    redirectURI

    Optional redirect URI that must match the one used during SSO login. Only used with Authorization Code flow.

    useAuthCode

    If true (default), the ssoToken is treated as an authorization code. If false, it is treated as an ID token (Implicit flow).

    Return Value

    Array of UserLicensesData

  • Version of LicenseSpring SDK

    Declaration

    Swift

    @objc
    static let sdkVersion: String
  • Version of LicenseSpring API

    Declaration

    Swift

    @objc
    static let apiVersion: Int
  • Version of FloatingServerV2 API

    Declaration

    Swift

    @objc
    static let fsV2ApiVersion: Int
  • Undocumented

    Declaration

    Swift

    func reconfigure(appName: String? = nil, appVersion: String? = nil, customerAccountCode: String? = nil, airgapKey: String? = nil, serviceURL: URL? = nil, hardwareID: String? = nil, collectHostNameAndLocalIP: Bool? = nil, networkTimeout: TimeInterval? = nil, proxyHost: String? = nil, proxyPort: UInt16? = nil, gracePeriod: TimeInterval? = nil, skipResponseSignatureChecks: Bool? = nil, client_id: String? = nil, client_secret: String? = nil, CryptoProviderKey: String? = nil, isOauth: Bool? = nil, extendedOptions: ExtendedOptions? = nil) throws
  • Extract SSO license token from URL.

    Throws

    Error if urlString has invalid format or scheme mismatched.

    Declaration

    Swift

    @objc
    static func extractSSOToken(from urlString: String, scheme: String, useAuthCode: Bool = true) throws -> String

    Parameters

    scheme

    Expected URL scheme to ensure URL is valid. If scheme mismatched, the error is thrown.

    useAuthCode

    If true (default), extracts the code query parameter (Authorization Code flow). If false, extracts the id_token fragment (Implicit flow).

    Return Value

    SSO token to activate the license.